import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [AutoImport({
        resolvers: [ElementPlusResolver()],
    }),
        Components({
            resolvers: [ElementPlusResolver()],
        }),
    vue()],
    transpileDependencies: true,
    // publicPath: '/',
    // outputDir: 'dist',
    devServer: {
        port: 8088,   // 端口号
    },
    server: {
        // host: 'localhost',  // 此前端项目的IP地址
        // port: 5173,  // 此前端项目的端口号
        // open: true,  //表示在启动开发服务器时，会自动打开浏览器并访问指定的地址
        proxy: {
            '/api': {
                target: 'http://localhost:8081', //接口域名
                changeOrigin: true,       //是否跨域
                ws: true,            //是否代理 websockets
                secure: true,          //是否https接口
                pathRewrite: {
                    '^/api': ''  //假如我们的地址是 /api/member/getToken 会转化为 /member/getToken
                }
            }
        }
    }
})


